import { createRouter, createWebHistory } from 'vue-router';
import { useStore } from 'vuex';
// 确保路径正确，检查文件是否存在以及导出方式是否正确
import layout from '../Layout';
import { fa } from 'element-plus/es/locales.mjs';

const routes = [
  {
    //登陆页
    path: '/login',
    name: 'login',
    component: () => import('@/views/LoginPage.vue'),
    meta: { requiresAuth: false, roles: ['admin'] }
  },
  // {
  //   //404
  //   path: '/:pathMatch(.*)*',
  //   name: '404',
  //   component: () => import('@/views/NotFoundPage.vue'),
  //   meta: { requiresAuth: false }
  // }
];

export const defaultMenuRoutes = [
  {
    //主页
    path: '',
    name: 'home',
    component: layout,
    redirect: 'index',
    children: [
      {
        //欢迎页
        path: '/index',
        name: 'index',
        component: () => import('@/views/WelcomePage.vue'),
        meta: { title: '主页', icon: 'Document' ,affix :false, roles: ['admin']},
      },
    ]
  },

];


const router = createRouter({
  history: createWebHistory(),
  routes: [...routes, ...defaultMenuRoutes],
});

export default router;